﻿using Quartz;
using System;
using System.Data;
using System.Data.Common;
using MyCode.Project.Services;
using MyCode.Project.Infrastructure;
using MyCode.Project.Infrastructure.UnityExtensions;
using Microsoft.Practices.Unity;
using System.Reflection;
using MyCode.Project.Domain.Model;
using System.Collections;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Threading;
using MyCode.Project.Infrastructure.Common;
using System.Threading.Tasks;
using MyCode.Project.Infrastructure.WebPost;

namespace MyCode.Project.ScheduleTask.Jobs
{
	public class EveryHourJob : IJob
    {

		private readonly IStorageService _storageService;
       

        public EveryHourJob(IStorageService storageService)
		{
            _storageService = storageService;  
        }
		public void Execute(IJobExecutionContext context)
        {
         
            _storageService.SendChatBeforeOneHour();//会话页面--预约时间前一个小时到店提醒
            DingDingSendMsg("正常运行中:" + DateTime.Now);
        }

        #region SendMsg(发送信息)
        private static Task DingDingSendMsg(string content)
        {
            string url = WebConfigUtils.GetAppSettingsInfo("DingDingApiUrl");
            string _txt = "websocket" + WebConfigUtils.GetAppSettingsInfo("DingDingTxt");
            WebUtils webUtils = new WebUtils();
            var jsonObject = new { msgtype = "text", text = new { content = _txt + content } };

            var jsonStr = JsonHelper.ToJson(jsonObject);

            var result = webUtils.DoPostJson(url, jsonStr);

            return Task.CompletedTask;

        }
        #endregion
    }
}

